package com.five.second_shop.config;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;



@Configuration
public class Myconfig extends WebMvcConfigurerAdapter {
    @Autowired
    private LoginHandlerInterceptor loginHandlerInterceptor;
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String path = "D:\\campusshops\\file\\";
        registry.addResourceHandler("/pic/**").addResourceLocations("file:" + path);
        super.addResourceHandlers(registry);
    }

    /**
     * 添加的拦截器
     * @param registry
     */
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(loginHandlerInterceptor)
                .addPathPatterns("/admin/**")
                .addPathPatterns("/user/center")
                .addPathPatterns("/user/orderList","/user/pass","/product-shopCar")
                .addPathPatterns("/user/perfectinfo")
               /*白名单*/
                .excludePathPatterns("/admin","/admin/login","/alipay/**");
        super.addInterceptors(registry);
    }
}
